home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / SpeechSynthesis.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  12.7 KB  |  388 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        SpeechSynthesis.h
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1989-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __SPEECHSYNTHESIS__
  18. #define __SPEECHSYNTHESIS__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __MIXEDMODE__
  24. #include <MixedMode.h>
  25. #endif
  26. #ifndef __FILES__
  27. #include <Files.h>
  28. #endif
  29.  
  30.  
  31.  
  32. #if PRAGMA_ONCE
  33. #pragma once
  34. #endif
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_IMPORT
  41. #pragma import on
  42. #endif
  43.  
  44. #if PRAGMA_STRUCT_ALIGN
  45.     #pragma options align=mac68k
  46. #elif PRAGMA_STRUCT_PACKPUSH
  47.     #pragma pack(push, 2)
  48. #elif PRAGMA_STRUCT_PACK
  49.     #pragma pack(2)
  50. #endif
  51.  
  52.  
  53. enum {
  54.     kTextToSpeechSynthType        = FOUR_CHAR_CODE('ttsc'),
  55.     kTextToSpeechVoiceType        = FOUR_CHAR_CODE('ttvd'),
  56.     kTextToSpeechVoiceFileType    = FOUR_CHAR_CODE('ttvf'),
  57.     kTextToSpeechVoiceBundleType = FOUR_CHAR_CODE('ttvb')
  58. };
  59.  
  60.  
  61. enum {
  62.     kNoEndingProsody            = 1,
  63.     kNoSpeechInterrupt            = 2,
  64.     kPreflightThenPause            = 4
  65. };
  66.  
  67.  
  68. enum {
  69.     kImmediate                    = 0,
  70.     kEndOfWord                    = 1,
  71.     kEndOfSentence                = 2
  72. };
  73.  
  74.  
  75. /*------------------------------------------*/
  76. /* GetSpeechInfo & SetSpeechInfo selectors    */
  77. /*------------------------------------------*/
  78.  
  79. enum {
  80.     soStatus                    = FOUR_CHAR_CODE('stat'),
  81.     soErrors                    = FOUR_CHAR_CODE('erro'),
  82.     soInputMode                    = FOUR_CHAR_CODE('inpt'),
  83.     soCharacterMode                = FOUR_CHAR_CODE('char'),
  84.     soNumberMode                = FOUR_CHAR_CODE('nmbr'),
  85.     soRate                        = FOUR_CHAR_CODE('rate'),
  86.     soPitchBase                    = FOUR_CHAR_CODE('pbas'),
  87.     soPitchMod                    = FOUR_CHAR_CODE('pmod'),
  88.     soVolume                    = FOUR_CHAR_CODE('volm'),
  89.     soSynthType                    = FOUR_CHAR_CODE('vers'),
  90.     soRecentSync                = FOUR_CHAR_CODE('sync'),
  91.     soPhonemeSymbols            = FOUR_CHAR_CODE('phsy'),
  92.     soCurrentVoice                = FOUR_CHAR_CODE('cvox'),
  93.     soCommandDelimiter            = FOUR_CHAR_CODE('dlim'),
  94.     soReset                        = FOUR_CHAR_CODE('rset'),
  95.     soCurrentA5                    = FOUR_CHAR_CODE('myA5'),
  96.     soRefCon                    = FOUR_CHAR_CODE('refc'),
  97.     soTextDoneCallBack            = FOUR_CHAR_CODE('tdcb'),        /* use with SpeechTextDoneProcPtr*/
  98.     soSpeechDoneCallBack        = FOUR_CHAR_CODE('sdcb'),        /* use with SpeechDoneProcPtr*/
  99.     soSyncCallBack                = FOUR_CHAR_CODE('sycb'),        /* use with SpeechSyncProcPtr*/
  100.     soErrorCallBack                = FOUR_CHAR_CODE('ercb'),        /* use with SpeechErrorProcPtr*/
  101.     soPhonemeCallBack            = FOUR_CHAR_CODE('phcb'),        /* use with SpeechPhonemeProcPtr*/
  102.     soWordCallBack                = FOUR_CHAR_CODE('wdcb'),
  103.     soSynthExtension            = FOUR_CHAR_CODE('xtnd'),
  104.     soSoundOutput                = FOUR_CHAR_CODE('sndo')
  105. };
  106.  
  107.  
  108. /*------------------------------------------*/
  109. /* Speaking Mode Constants                     */
  110. /*------------------------------------------*/
  111.  
  112. enum {
  113.     modeText                    = FOUR_CHAR_CODE('TEXT'),        /* input mode constants                     */
  114.     modePhonemes                = FOUR_CHAR_CODE('PHON'),
  115.     modeNormal                    = FOUR_CHAR_CODE('NORM'),        /* character mode and number mode constants */
  116.     modeLiteral                    = FOUR_CHAR_CODE('LTRL')
  117. };
  118.  
  119.  
  120.  
  121. enum {
  122.     soVoiceDescription            = FOUR_CHAR_CODE('info'),
  123.     soVoiceFile                    = FOUR_CHAR_CODE('fref')
  124. };
  125.  
  126.  
  127. typedef struct OpaqueSpeechChannel*     SpeechChannel;
  128.  
  129.  
  130. struct VoiceSpec {
  131.     OSType                             creator;
  132.     OSType                             id;
  133. };
  134. typedef struct VoiceSpec                VoiceSpec;
  135. typedef VoiceSpec *                        VoiceSpecPtr;
  136.  
  137.  
  138. enum {
  139.     kNeuter                        = 0,
  140.     kMale                        = 1,
  141.     kFemale                        = 2
  142. };
  143.  
  144.  
  145.  
  146.  
  147.  
  148. struct VoiceDescription {
  149.     long                             length;
  150.     VoiceSpec                         voice;
  151.     long                             version;
  152.     Str63                             name;
  153.     Str255                             comment;
  154.     short                             gender;
  155.     short                             age;
  156.     short                             script;
  157.     short                             language;
  158.     short                             region;
  159.     long                             reserved[4];
  160. };
  161. typedef struct VoiceDescription            VoiceDescription;
  162.  
  163.  
  164.  
  165. struct VoiceFileInfo {
  166.     FSSpec                             fileSpec;
  167.     short                             resID;
  168. };
  169. typedef struct VoiceFileInfo            VoiceFileInfo;
  170.  
  171. struct SpeechStatusInfo {
  172.     Boolean                         outputBusy;
  173.     Boolean                         outputPaused;
  174.     long                             inputBytesLeft;
  175.     short                             phonemeCode;
  176. };
  177. typedef struct SpeechStatusInfo            SpeechStatusInfo;
  178.  
  179.  
  180.  
  181. struct SpeechErrorInfo {
  182.     short                             count;
  183.     OSErr                             oldest;
  184.     long                             oldPos;
  185.     OSErr                             newest;
  186.     long                             newPos;
  187. };
  188. typedef struct SpeechErrorInfo            SpeechErrorInfo;
  189.  
  190.  
  191.  
  192. struct SpeechVersionInfo {
  193.     OSType                             synthType;
  194.     OSType                             synthSubType;
  195.     OSType                             synthManufacturer;
  196.     long                             synthFlags;
  197.     NumVersion                         synthVersion;
  198. };
  199. typedef struct SpeechVersionInfo        SpeechVersionInfo;
  200.  
  201.  
  202.  
  203. struct PhonemeInfo {
  204.     short                             opcode;
  205.     Str15                             phStr;
  206.     Str31                             exampleStr;
  207.     short                             hiliteStart;
  208.     short                             hiliteEnd;
  209. };
  210. typedef struct PhonemeInfo                PhonemeInfo;
  211.  
  212.  
  213. struct PhonemeDescriptor {
  214.     short                             phonemeCount;
  215.     PhonemeInfo                     thePhonemes[1];
  216. };
  217. typedef struct PhonemeDescriptor        PhonemeDescriptor;
  218.  
  219. struct SpeechXtndData {
  220.     OSType                             synthCreator;
  221.     Byte                             synthData[2];
  222. };
  223. typedef struct SpeechXtndData            SpeechXtndData;
  224.  
  225.  
  226. struct DelimiterInfo {
  227.     Byte                             startDelimiter[2];
  228.     Byte                             endDelimiter[2];
  229. };
  230. typedef struct DelimiterInfo            DelimiterInfo;
  231.  
  232. typedef CALLBACK_API( void , SpeechTextDoneProcPtr )(SpeechChannel chan, long refCon, const void **nextBuf, unsigned long *byteLen, long *controlFlags);
  233. typedef CALLBACK_API( void , SpeechDoneProcPtr )(SpeechChannel chan, long refCon);
  234. typedef CALLBACK_API( void , SpeechSyncProcPtr )(SpeechChannel chan, long refCon, OSType syncMessage);
  235. typedef CALLBACK_API( void , SpeechErrorProcPtr )(SpeechChannel chan, long refCon, OSErr theError, long bytePos);
  236. typedef CALLBACK_API( void , SpeechPhonemeProcPtr )(SpeechChannel chan, long refCon, short phonemeOpcode);
  237. typedef CALLBACK_API( void , SpeechWordProcPtr )(SpeechChannel chan, long refCon, unsigned long wordPos, unsigned short wordLen);
  238. typedef STACK_UPP_TYPE(SpeechTextDoneProcPtr)                     SpeechTextDoneUPP;
  239. typedef STACK_UPP_TYPE(SpeechDoneProcPtr)                         SpeechDoneUPP;
  240. typedef STACK_UPP_TYPE(SpeechSyncProcPtr)                         SpeechSyncUPP;
  241. typedef STACK_UPP_TYPE(SpeechErrorProcPtr)                         SpeechErrorUPP;
  242. typedef STACK_UPP_TYPE(SpeechPhonemeProcPtr)                     SpeechPhonemeUPP;
  243. typedef STACK_UPP_TYPE(SpeechWordProcPtr)                         SpeechWordUPP;
  244. enum { uppSpeechTextDoneProcInfo = 0x0000FFC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  245. enum { uppSpeechDoneProcInfo = 0x000003C0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes) */
  246. enum { uppSpeechSyncProcInfo = 0x00000FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes) */
  247. enum { uppSpeechErrorProcInfo = 0x00003BC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes, 4_bytes) */
  248. enum { uppSpeechPhonemeProcInfo = 0x00000BC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes) */
  249. enum { uppSpeechWordProcInfo = 0x00002FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 2_bytes) */
  250. #define NewSpeechTextDoneProc(userRoutine)                         (SpeechTextDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, GetCurrentArchitecture())
  251. #define NewSpeechDoneProc(userRoutine)                             (SpeechDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechDoneProcInfo, GetCurrentArchitecture())
  252. #define NewSpeechSyncProc(userRoutine)                             (SpeechSyncUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechSyncProcInfo, GetCurrentArchitecture())
  253. #define NewSpeechErrorProc(userRoutine)                         (SpeechErrorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechErrorProcInfo, GetCurrentArchitecture())
  254. #define NewSpeechPhonemeProc(userRoutine)                         (SpeechPhonemeUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, GetCurrentArchitecture())
  255. #define NewSpeechWordProc(userRoutine)                             (SpeechWordUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechWordProcInfo, GetCurrentArchitecture())
  256. #define CallSpeechTextDoneProc(userRoutine, chan, refCon, nextBuf, byteLen, controlFlags)  CALL_FIVE_PARAMETER_UPP((userRoutine), uppSpeechTextDoneProcInfo, (chan), (refCon), (nextBuf), (byteLen), (controlFlags))
  257. #define CallSpeechDoneProc(userRoutine, chan, refCon)             CALL_TWO_PARAMETER_UPP((userRoutine), uppSpeechDoneProcInfo, (chan), (refCon))
  258. #define CallSpeechSyncProc(userRoutine, chan, refCon, syncMessage)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechSyncProcInfo, (chan), (refCon), (syncMessage))
  259. #define CallSpeechErrorProc(userRoutine, chan, refCon, theError, bytePos)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechErrorProcInfo, (chan), (refCon), (theError), (bytePos))
  260. #define CallSpeechPhonemeProc(userRoutine, chan, refCon, phonemeOpcode)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechPhonemeProcInfo, (chan), (refCon), (phonemeOpcode))
  261. #define CallSpeechWordProc(userRoutine, chan, refCon, wordPos, wordLen)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechWordProcInfo, (chan), (refCon), (wordPos), (wordLen))
  262. EXTERN_API( NumVersion )
  263. SpeechManagerVersion            (void)                                                        FOURWORDINLINE(0x203C, 0x0000, 0x000C, 0xA800);
  264.  
  265. EXTERN_API( OSErr )
  266. MakeVoiceSpec                    (OSType                 creator,
  267.                                  OSType                 id,
  268.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x0604, 0x000C, 0xA800);
  269.  
  270. EXTERN_API( OSErr )
  271. CountVoices                        (short *                numVoices)                            FOURWORDINLINE(0x203C, 0x0108, 0x000C, 0xA800);
  272.  
  273. EXTERN_API( OSErr )
  274. GetIndVoice                        (short                     index,
  275.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x030C, 0x000C, 0xA800);
  276.  
  277. EXTERN_API( OSErr )
  278. GetVoiceDescription                (const VoiceSpec *        voice,
  279.                                  VoiceDescription *        info,
  280.                                  long                     infoLength)                            FOURWORDINLINE(0x203C, 0x0610, 0x000C, 0xA800);
  281.  
  282. EXTERN_API( OSErr )
  283. GetVoiceInfo                    (const VoiceSpec *        voice,
  284.                                  OSType                 selector,
  285.                                  void *                    voiceInfo)                            FOURWORDINLINE(0x203C, 0x0614, 0x000C, 0xA800);
  286.  
  287. EXTERN_API( OSErr )
  288. NewSpeechChannel                (VoiceSpecPtr             voice,
  289.                                  SpeechChannel *        chan)                                FOURWORDINLINE(0x203C, 0x0418, 0x000C, 0xA800);
  290.  
  291. EXTERN_API( OSErr )
  292. DisposeSpeechChannel            (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x021C, 0x000C, 0xA800);
  293.  
  294. EXTERN_API( OSErr )
  295. SpeakString                        (ConstStr255Param         textToBeSpoken)                        FOURWORDINLINE(0x203C, 0x0220, 0x000C, 0xA800);
  296.  
  297. EXTERN_API( OSErr )
  298. SpeakText                        (SpeechChannel             chan,
  299.                                  const void *            textBuf,
  300.                                  unsigned long             textBytes)                            FOURWORDINLINE(0x203C, 0x0624, 0x000C, 0xA800);
  301.  
  302. EXTERN_API( OSErr )
  303. SpeakBuffer                        (SpeechChannel             chan,
  304.                                  const void *            textBuf,
  305.                                  unsigned long             textBytes,
  306.                                  long                     controlFlags)                        FOURWORDINLINE(0x203C, 0x0828, 0x000C, 0xA800);
  307.  
  308. EXTERN_API( OSErr )
  309. StopSpeech                        (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x022C, 0x000C, 0xA800);
  310.  
  311. EXTERN_API( OSErr )
  312. StopSpeechAt                    (SpeechChannel             chan,
  313.                                  long                     whereToStop)                        FOURWORDINLINE(0x203C, 0x0430, 0x000C, 0xA800);
  314.  
  315. EXTERN_API( OSErr )
  316. PauseSpeechAt                    (SpeechChannel             chan,
  317.                                  long                     whereToPause)                        FOURWORDINLINE(0x203C, 0x0434, 0x000C, 0xA800);
  318.  
  319. EXTERN_API( OSErr )
  320. ContinueSpeech                    (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x0238, 0x000C, 0xA800);
  321.  
  322. EXTERN_API( short )
  323. SpeechBusy                        (void)                                                        FOURWORDINLINE(0x203C, 0x003C, 0x000C, 0xA800);
  324.  
  325. EXTERN_API( short )
  326. SpeechBusySystemWide            (void)                                                        FOURWORDINLINE(0x203C, 0x0040, 0x000C, 0xA800);
  327.  
  328. EXTERN_API( OSErr )
  329. SetSpeechRate                    (SpeechChannel             chan,
  330.                                  Fixed                     rate)                                FOURWORDINLINE(0x203C, 0x0444, 0x000C, 0xA800);
  331.  
  332. EXTERN_API( OSErr )
  333. GetSpeechRate                    (SpeechChannel             chan,
  334.                                  Fixed *                rate)                                FOURWORDINLINE(0x203C, 0x0448, 0x000C, 0xA800);
  335.  
  336. EXTERN_API( OSErr )
  337. SetSpeechPitch                    (SpeechChannel             chan,
  338.                                  Fixed                     pitch)                                FOURWORDINLINE(0x203C, 0x044C, 0x000C, 0xA800);
  339.  
  340. EXTERN_API( OSErr )
  341. GetSpeechPitch                    (SpeechChannel             chan,
  342.                                  Fixed *                pitch)                                FOURWORDINLINE(0x203C, 0x0450, 0x000C, 0xA800);
  343.  
  344. EXTERN_API( OSErr )
  345. SetSpeechInfo                    (SpeechChannel             chan,
  346.                                  OSType                 selector,
  347.                                  const void *            speechInfo)                            FOURWORDINLINE(0x203C, 0x0654, 0x000C, 0xA800);
  348.  
  349. EXTERN_API( OSErr )
  350. GetSpeechInfo                    (SpeechChannel             chan,
  351.                                  OSType                 selector,
  352.                                  void *                    speechInfo)                            FOURWORDINLINE(0x203C, 0x0658, 0x000C, 0xA800);
  353.  
  354. EXTERN_API( OSErr )
  355. TextToPhonemes                    (SpeechChannel             chan,
  356.                                  const void *            textBuf,
  357.                                  unsigned long             textBytes,
  358.                                  Handle                 phonemeBuf,
  359.                                  long *                    phonemeBytes)                        FOURWORDINLINE(0x203C, 0x0A5C, 0x000C, 0xA800);
  360.  
  361. EXTERN_API( OSErr )
  362. UseDictionary                    (SpeechChannel             chan,
  363.                                  Handle                 dictionary)                            FOURWORDINLINE(0x203C, 0x0460, 0x000C, 0xA800);
  364.  
  365.  
  366.  
  367.  
  368. #if PRAGMA_STRUCT_ALIGN
  369.     #pragma options align=reset
  370. #elif PRAGMA_STRUCT_PACKPUSH
  371.     #pragma pack(pop)
  372. #elif PRAGMA_STRUCT_PACK
  373.     #pragma pack()
  374. #endif
  375.  
  376. #ifdef PRAGMA_IMPORT_OFF
  377. #pragma import off
  378. #elif PRAGMA_IMPORT
  379. #pragma import reset
  380. #endif
  381.  
  382. #ifdef __cplusplus
  383. }
  384. #endif
  385.  
  386. #endif /* __SPEECHSYNTHESIS__ */
  387.  
  388.